package avicit.bdp.dgs.qa.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.core.constant.Constants;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2023-03-29
 * @类说明：JobDTO
 * @修改记录：
 * @注意事项：
 * @主要功能：质量作业DTO
 */
@ApiModel(value = "JobDTO", description = "质量作业DTO")
@Table(name = "bdp_dgs_qa_job")
public class JobDTO extends BaseDTO {
    /**
     * 主键
     */
    @Id
    @LogField
    @ApiModelProperty(value = "主键")
    @FieldRemark(column = "id", field = "id", name = "id")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 名称
     */
    @LogField
    @ApiModelProperty(value = "名称")
    @FieldRemark(column = "name", field = "name", name = "名称")
    @Column(name = "name")
    private String name;

    /**
     * 描述
     */
    @LogField
    @ApiModelProperty(value = "描述")
    @FieldRemark(column = "remark", field = "remark", name = "描述")
    @Column(name = "remark")
    private String remark;

    /**
     * 校验类型，0:单表校验、1:跨表比对、2:跨库比对、3:文件校验、4:单指标校验、5:多指标校验、6:根据数据标准校验
     */
    @LogField
    @ApiModelProperty(value = "校验类型，0:单表校验、1:跨表比对、2:跨库比对、3:文件校验、4:单指标校验、5:多指标校验、6:根据数据标准校验")
    @FieldRemark(column = "measureType", field = "measureType", name = "measureType")
    @Column(name = "measure_type")
    private Integer measureType;
    @Transient
    private String measureTypeName;

    /**
     * 数据源ID
     */
    @LogField
    @ApiModelProperty(value = "数据源ID")
    @FieldRemark(column = "datasourceId", field = "datasourceId", name = "datasourceId")
    @Column(name = "datasource_id")
    private String datasourceId;
    @Transient
    private String datasourceName;

    /**
     * 库名称
     */
    @LogField
    @ApiModelProperty(value = "库名称")
    @FieldRemark(column = "dbName", field = "dbName", name = "dbName")
    @Column(name = "db_name")
    private String dbName;

    /**
     * 表名称
     */
    @LogField
    @ApiModelProperty(value = "表名称")
    @FieldRemark(column = "tableName", field = "tableName", name = "tableName")
    @Column(name = "table_name")
    private String tableName;

    /**
     * 状态，0--提交成功；1--运行中；2--准备暂停；3--暂停；4-准备停止；5--停止；6--失败；
     *      7--成功；8-需要容错；9-kill；10-等待线程；11-等待依赖加载
     */
    @LogField
    @ApiModelProperty(value = "状态,0:草稿、1:运行中、5:停止、6:失败、7:成功")
    @FieldRemark(column = "state", field = "state", name = "state")
    @Column(name = "state")
    private Integer state;
    @Transient
    private String stateName;

    /**
     * 调度方式
     */
    @LogField
    @ApiModelProperty(value = "调度方式,0:手动执行、1:定时执行、2:自动执行")
    @FieldRemark(column = "schedulerType", field = "schedulerType", name = "schedulerType")
    @Column(name = "scheduler_type")
    private Integer schedulerType;
    @Transient
    private String schedulerTypeName;

    /**
     * 是否启用定时
     */
    @LogField
    @ApiModelProperty(value = "是否启用定时,0:未启用定时、1:启用定时")
    @FieldRemark(column = "schedulerType", field = "enableCrontab", name = "是否启用定时")
    @Column(name = "enable_crontab")
    private Integer enableCrontab;

    /**
     * 校验结果,0:正常、1:报警、2:失败
     */
    @LogField
    @ApiModelProperty(value = "校验结果,0:正常、1:报警、2:失败")
    @FieldRemark(column = "resultType", field = "resultType", name = "resultType")
    @Column(name = "result_type")
    private Integer resultType;
    @Transient
    private String resultTypeName;

    /**
     * 流程实例ID
     */
    @LogField
    @ApiModelProperty(value = "流程实例ID")
    @FieldRemark(column = "processInstanceId", field = "processInstanceId", name = "processInstanceId")
    @Column(name = "process_instance_id")
    private String processInstanceId;

    /**
     * 附加字段(文件校验时使用)
     */
    @LogField
    @ApiModelProperty(value = "附加字段")
    @FieldRemark(column = "attr", field = "attr", name = "附加字段")
    @Column(name = "attr")
    private String attr;

    /**
     * 质量作业关联的数据源列表，保存在bdp_dgs_qa_datasource表中.
     */
    @Transient
    List<QaDataSourceDTO> dataSourceList;

    /**
     * 下次执行时间
     */
    @Transient
    private String nextExecTime;

    /**
     * 任务开始执行时间，结束执行时间
     */
    @Transient
    @JsonFormat(pattern = Constants.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
    private Date startTime;
    @Transient
    @JsonFormat(pattern = Constants.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
    private Date endTime;

    /****************************文件校验相关参数****************************/
    /**
     * 试飞信息主键ID
     */
    @Transient
    private String offsiteDataId;

    /**
     * 试飞文件类型，0：试飞原始数据、1：工程值数据
     */
    @Transient
    private Integer fileType;
    @Transient
    private String fileTypeName;

    /**
     * 试飞数据类型，包括PCM、1153B、FCS、INET
     */
    @Transient
    private String dataProp;

    /**
     * 试飞类别
     */
    @Transient
    private String type;

    /**
     * 试飞型号名称
     */
    @Transient
    private String typeName;

    /**
     * 试飞型号
     */
    @Transient
    private String modelCode;

    /**
     * 试飞机型
     */
    @Transient
    private String aircraftName;

    /**
     * 试飞架次
     */
    @Transient
    private String sortie;

    /**
     * 试飞飞行日期
     */
    @Transient
    private String flightDate;

    /**
     * 试飞测试系统
     */
    @Transient
    private String testSystemName;

    /**
     * 待校验文件ID列表
     */
    @Transient
    private List<String> fileIdList;

    /**
     * 附件ID，多个附件使用英文逗号隔开
     */
    @Transient
    private String resourceIds;

    /**
     * 文件校验日志（自动执行）
     */
    @Transient
    private String log;
    /****************************文件校验相关参数****************************/

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Integer getMeasureType() {
        return measureType;
    }

    public void setMeasureType(Integer measureType) {
        this.measureType = measureType;
    }

    public String getMeasureTypeName() {
        return measureTypeName;
    }

    public void setMeasureTypeName(String measureTypeName) {
        this.measureTypeName = measureTypeName;
    }

    public String getDatasourceId() {
        return datasourceId;
    }

    public void setDatasourceId(String datasourceId) {
        this.datasourceId = datasourceId;
    }

    public String getDatasourceName() {
        return datasourceName;
    }

    public void setDatasourceName(String datasourceName) {
        this.datasourceName = datasourceName;
    }

    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public Integer getSchedulerType() {
        return schedulerType;
    }

    public void setSchedulerType(Integer schedulerType) {
        this.schedulerType = schedulerType;
    }

    public String getSchedulerTypeName() {
        return schedulerTypeName;
    }

    public void setSchedulerTypeName(String schedulerTypeName) {
        this.schedulerTypeName = schedulerTypeName;
    }

    public Integer getEnableCrontab() {
        return enableCrontab;
    }

    public void setEnableCrontab(Integer enableCrontab) {
        this.enableCrontab = enableCrontab;
    }

    public Integer getResultType() {
        return resultType;
    }

    public void setResultType(Integer resultType) {
        this.resultType = resultType;
    }

    public String getResultTypeName() {
        return resultTypeName;
    }

    public void setResultTypeName(String resultTypeName) {
        this.resultTypeName = resultTypeName;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public String getAttr() {
        return attr;
    }

    public void setAttr(String attr) {
        this.attr = attr;
    }

    public List<QaDataSourceDTO> getDataSourceList() {
        return dataSourceList;
    }

    public void setDataSourceList(List<QaDataSourceDTO> dataSourceList) {
        this.dataSourceList = dataSourceList;
    }

    public String getNextExecTime() {
        return nextExecTime;
    }

    public void setNextExecTime(String nextExecTime) {
        this.nextExecTime = nextExecTime;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public String getOffsiteDataId() {
        return offsiteDataId;
    }

    public void setOffsiteDataId(String offsiteDataId) {
        this.offsiteDataId = offsiteDataId;
    }

    public Integer getFileType() {
        return fileType;
    }

    public void setFileType(Integer fileType) {
        this.fileType = fileType;
    }

    public String getFileTypeName() {
        return fileTypeName;
    }

    public void setFileTypeName(String fileTypeName) {
        this.fileTypeName = fileTypeName;
    }

    public String getDataProp() {
        return dataProp;
    }

    public void setDataProp(String dataProp) {
        this.dataProp = dataProp;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public String getModelCode() {
        return modelCode;
    }

    public void setModelCode(String modelCode) {
        this.modelCode = modelCode;
    }

    public String getAircraftName() {
        return aircraftName;
    }

    public void setAircraftName(String aircraftName) {
        this.aircraftName = aircraftName;
    }

    public String getSortie() {
        return sortie;
    }

    public void setSortie(String sortie) {
        this.sortie = sortie;
    }

    public String getFlightDate() {
        return flightDate;
    }

    public void setFlightDate(String flightDate) {
        this.flightDate = flightDate;
    }

    public String getTestSystemName() {
        return testSystemName;
    }

    public void setTestSystemName(String testSystemName) {
        this.testSystemName = testSystemName;
    }

    public List<String> getFileIdList() {
        return fileIdList;
    }

    public void setFileIdList(List<String> fileIdList) {
        this.fileIdList = fileIdList;
    }

    public String getResourceIds() {
        return resourceIds;
    }

    public void setResourceIds(String resourceIds) {
        this.resourceIds = resourceIds;
    }

    public String getLog() {
        return log;
    }

    public void setLog(String log) {
        this.log = log;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "质量任务模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "质量任务";
        } else {
            return super.logTitle;
        }
    }
}
